#include "NameValidator.h"

NameValidator::NameValidator(int min_chars):NotEmptyValidator("")
{
	this->min_chars = min_chars;
}

NameValidator::~NameValidator(void)
{
}

int NameValidator::validate(const QString & input)
{
	if(input.isEmpty())
		return -1;
	bool ok = true;
	QString last = input.right(1);
	last.toInt(&ok);
	if(ok)
	{
		return -2;
	}
	const char* lastChar = last.toLatin1().data();
	switch(lastChar[0])
	{
	case '"': 
		return -2;
	}
	if(input.length() < min_chars)
		return -1;
	return 0;
}